from flask_restful import Resource

from restful.api__.session import login_required_current_user_generate, uid_required_target_user_generate
from restful.model.query import QueryOneInstance
from restful.model.tables import User
from restful.response import ResponseSuccess


class UserName(Resource):
    @login_required_current_user_generate
    @uid_required_target_user_generate
    def get(self,target_user,current_user):
        user = QueryOneInstance(User,{'id':target_user.id})
        return ResponseSuccess(data={
            'username':user.username
        })